package chabernac.android.wordbattle.paint.crosstile;

import android.graphics.Bitmap;
import android.graphics.Point;
import android.graphics.Rect;
import chabernac.android.wordbattle.WordBattleView;
import chabernac.android.wordbattle.model.Letter;
import chabernac.android.wordbattle.model.Word;

public class HalfRightCrossTileDrawable extends AbstractHalfCrossTileDrawable {

	public HalfRightCrossTileDrawable( Word aSelectedWord, Letter aRightUpLetter, Letter aRightDownLetter ) {
		super(aSelectedWord, aRightUpLetter, aRightDownLetter);
	}
	
	@Override
	protected Point getDrawingPoint(WordBattleView aWordBattleView) {
		int x = WordBattleView.BORDER_SIZE;
		int y = WordBattleView.BORDER_SIZE;
		// Horizontal left and vertical center of upper right Letter
	    x += (int)(this.myLetterUpOrLeft.getColumn() * aWordBattleView.getWidthPerColumn());
	    y += (int)(this.myLetterUpOrLeft.getRow() * aWordBattleView.getHeightPerRow());
		y += (int)(aWordBattleView.getHeightPerRow()/2);
		return new Point(x,y);
	}
	
	@Override
	protected Rect getBitmapSubsetRect(Bitmap aBitmap) {
		return new Rect((int)aBitmap.getWidth()/2,0,(int)aBitmap.getWidth(), (int)aBitmap.getHeight());
	}
	
	@Override
	protected boolean addSvgResourceNameSelectionStringSingleLetter(SvgResourceNameBuilder aBuilder, Letter aLetter)
	{
		if ( aLetter == null ) return false;
		boolean aLetterSelected = mySelectedWord.contains(aLetter);
		if(aLetterSelected == true)
		{
			if (aLetter == myLetterUpOrLeft)
			{
				aBuilder.appendSelectStringUpRight();
			}
			else if (aLetter == myLetterDownOrRight)
			{
				aBuilder.appendSelectStringDownRight();
			}
		}
		return aLetterSelected;
	}
}
